<template>
	<view class="content">

		<view class="goods_list_continor">
			<view class="goods_list_item" v-for="(item,index) in dataList" :key="index">
				<image :src="item.img" mode="aspectFill" class="goods_img"></image>
				<view class="goods_infos">
					<view class="goods_name">
						{{item.goodsName}}
					</view>
					<view class="price_info">
						<text>{{item.CurrentPrice}}</text><text class="source_price">{{item.OriginalPrice}}</text>
					</view>
					<view class="tags">
						<text>每满300减45</text>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				dataList: [{
							"goodsName": "石墨烯云空暖2500W",
							"img": "https://img.andou360.com/Departments_36/Projects_25/PMWYProduct/31993/6380110524664821310_2.jpg",
							CurrentPrice: 1288.99,
							OriginalPrice: 1899
						},
						{
							"goodsName": "星宇传奇干果礼盒",
							"img": "https://img.andou360.com/Departments_36/Projects_25/PMWYProduct/55/6378390917362942170_1.jpg",
							CurrentPrice: 128.99,
							OriginalPrice: 288.2
						}, {
							"goodsName": "星云嘉话干果礼盒",
							"img": "https://img.andou360.com/Departments_36/Projects_25/PMWYProduct/55/6378390945184521541_2.jpg",
							CurrentPrice: 199.99,
							OriginalPrice: 368
						},
						{
							"goodsName": "干菌礼盒林夏菌子",
							"img": "https://img.andou360.com/Departments_36/Projects_25/PMWYProduct/55/6378545790435839171_1.jpg",
							CurrentPrice:99.99,
							OriginalPrice: 199.99
						},
						{
							"goodsName": "干菌礼盒山林忆菌子",
							"img": "https://img.andou360.com/Departments_36/Projects_25/PMWYProduct/55/6378545878270984111_1.jpg",
							CurrentPrice: 256.4,
							OriginalPrice: 366.8
						},
						{
							"goodsName": "玛咖啤酒320ml听装好喝易拉罐装",
							"img": "https://img.andou360.com/Departments_36/Projects_25/PMWYProduct/31993/6380170966690907931_l.jpg",
							CurrentPrice: 128,
							OriginalPrice: 256
						},
						{
							"goodsName": "玛咖啤酒328ml听装好喝网红易拉罐装不上头",
							"img": "https://img.andou360.com/Departments_36/Projects_25/PMWYProduct/31993/6380170986801850411_l.png",
							CurrentPrice: 120,
							OriginalPrice: 248
						}
					],
					scene: '',
					noticeShow: false,
					adList: [],
					productList: []
				
			}
		},
		
			onLoad(option) {
				if (option.scene) {
					this.scene = option.scene
					this.$store.commit('user/SET_SCENE', option.scene)
				}
			// },
			// onReady() {
				this.wxLogin();
				this.getAdList()
			},
			onShow() {
				this.checkMarketShop()
				this.getProductList()
			},
			methods: {
				// 微信登录
				 wxLogin: function() {
					let that = this
					uni.login({
						provider: 'weixin',
						success:  function(loginRes) {
							console.log(loginRes)
							request.httpPost("mini/miniLogin", {
								'jsCode': loginRes.code
							}, false).then(res => {
								console.log('miniLogin', res)
								if (res.httpCode == 200) {
									uni.setStorageSync('wxOpenId', res.data.wxOpenId)
									that.$store.commit('user/SET_USERINFO', res.data)
								
								}
							});
						}
					})
				},
				checkMarketShop(){
					let that = this
					if (that.scene) {
						request.httpPost('mini/checkMarketShop', {
							shopCode: that.scene
						}, false).then(res => {
							console.log('checkMarketShop', res)
							if (res.httpCode == 200) {
								if (!res.data) {
									// that.$refs.uTips.show({
									// 	title: '商铺未绑定',
									// 					type: 'warning',
									// 					duration: '9999000'
									// })
									that.noticeShow = true
								} else {
									that.noticeShow = false
								}
					
							}else{
								that.$refs.uToast.show({
									title:res.msg
								})
							}
						})
					}
				},
				bindShop() {
					// console.log('进来了')
					if(uni.getStorageSync('wxOpenId')){
						uni.navigateTo({
							url: "../ucenter/bindShop/bindShop"
						})
					}else{
						this.$refs.uToast.show({
							title:'数据未加载完毕，请稍后重试'
						})
					}
					
				},
				getAdList() {
					let _that = this
					request.httpPost('mini/queryAdPosition', {
						'adPlace': '小程序轮播'
					}, false).then(res => {
						console.log(res)
						if (res.httpCode == 200) {
							_that.adList = res.data
						}
					})
				},
				getProductList() {
					let _that = this
					request.httpPost('mini/mallProductInfoList', {}, false).then(res => {
						console.log(res)
						if (res.httpCode == 200) {
							_that.productList = res.data
						}
					})
				},
				toProductInfo(id){
					uni.navigateTo({
						url:'../product/productInfo/productInfo?idProduct='+id
					})
				}
			}
		
	}
</script>

<style lang="less" scoped>
	.goods_list_continor {
			padding: 30rpx;
	
			.goods_list_item {
				display: flex;
				align-items: center;
				margin-bottom: 30rpx;
	
				.goods_img {
					width: 220rpx;
					height: 220rpx;
					border-radius: 10rpx;
					margin-right: 20rpx;
					flex-shrink: 0;
				}
	
				.goods_infos {
					font-size: 30rpx;
	
					.goods_name {
						overflow: hidden;
						text-overflow: ellipsis;
						display: -webkit-box;
						-webkit-line-clamp: 2;
						-webkit-box-orient: vertical;
						color: black;
					}
	
					.price_info {
						font-size: 35rpx;
						color: red;
						margin-top: 25rpx;
						font-weight: bold;
					}
	
					.price_info::before {
						content: '￥';
						font-size: 20rpx;
					}
	
					.source_price {
						color: gray;
						font-size: 25rpx;
						margin-left: 10rpx;
						text-decoration: line-through;
					}
	
					.tags {
						display: flex;
						font-size: 20rpx;
						line-height: 20rpx;
						margin-top: 5rpx;
	
						&>text {
							display: inline-block;
							color: red;
							border-radius: 8rpx;
							border: 1px solid red;
							padding: 5rpx;
						}
					}
				}
			}
		}
	
</style>